package com.ldn;

import cn.hutool.cron.CronUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author 李大牛家的牛 (scafel@163.com) 
 * @createDate 2024/7/9 - 16:09
 * @description ...
 **/
@SpringBootApplication(exclude = SpringDataWebAutoConfiguration.class)
@EnableAsync
@EnableTransactionManagement
@EnableScheduling
@MapperScan("com.ldn.dao.mapper")
public class ApiApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiApplication.class);
        // 支持秒级别定时任务
        CronUtil.setMatchSecond(true);
        CronUtil.start();
        Runtime.getRuntime().addShutdownHook(new ExitHook());
    }

}

class ExitHook extends Thread {
    @Override
    public void run() {
        super.run();
        CronUtil.stop();
    }
}